package huawei;

import java.util.Scanner;

/**
 * 十六进制转换成十进制
 */
public class HexToDec {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String hexString = sc.nextLine().trim();
            System.out.println(hexToDecString(hexString));
        }
    }

    private static String hexToDecString(String hexString) {
        if (hexString == null || hexString.length() < 3) return null;
        int dec = 0;
        int n = hexString.length();
        String s = hexString.toUpperCase();
        for (int i = 2; i < n; ++i) {
            dec = dec * 16 + decCharrToDec(s.charAt(i));
        }
        return "" + dec;
    }

    private static int decCharrToDec(char c) {
        if (c >= 'A' && c <= 'F') {
            return 10 + c - 'A';
        }
        return c - '0';
    }
}
